/* 
 *   Date       Developer   Description
 *   
 *
 *   Classname:  zzz.test.component.direct.Test02
 * 
 *   Date:   2014-3-7
 * 
 *   The source code contained in this listing is proprietary to
 *   HLJ POST YITONG INFO-NET CO.,LTD.
 * 
 *   Unauthorized copying, adaptation, distribution, use, or display
 *   is strictly prohibited.
 *   This software is Copyright 2014 HLJ POST YITONG INFO-NET CO.,LTD.
 */
package com.titan.demo.camel.sample.component.direct;

import org.apache.camel.CamelContext;
import org.apache.camel.ComponentConfiguration;
import org.apache.camel.EndpointConfiguration;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.direct.DirectComponent;
import org.apache.camel.impl.DefaultCamelContext;


/**
 *
 *
 * @author Administrator
 *
 */
public class Test02 {

    public static void main(String[] args) {
        try {
            CamelContext container = new DefaultCamelContext();
            container.addRoutes(new RouteBuilder() {
                public void configure() {
                    from("direct:a?block=true").to("direct:b");
                    from("direct:b").process(new Processor() {
                        public void process(Exchange e) {
                            System.out.println(e.getFromEndpoint().getEndpointUri());
                        }
                    });
                }
            });
            
            DirectComponent com = container.getComponent("direct", DirectComponent.class);
            ComponentConfiguration compConf = com.createComponentConfiguration();
            String json = compConf.createParameterJsonSchema();
            System.out.println("json="+json);

//          EndpointConfiguration conf = container.getEndpoint("direct:a").getEndpointConfiguration();
            EndpointConfiguration conf = com.createConfiguration("direct:foo?block=true");
            System.out.println("block="+conf.getParameter("block"));
            
            String html = container.getComponentDocumentation("direct");
            System.out.println("html="+html);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

